package com.cn.common;

public class PullRequest {
    private String consumerGroup;
    private MessageQueue messageQueue;
    private ProcessQueue processQueue;
    //下一次拉取位置
    private long nextOffset = 0l;
    //是否第一次拉取
    private boolean lockFirst = false;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (this.consumerGroup == null ? 0 : this.consumerGroup.hashCode());
        result = prime * result + (this.messageQueue == null ? 0 : this.messageQueue.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (this == obj) return true;
        if (this.getClass() != obj.getClass()) return false;
        PullRequest other = (PullRequest) obj;
        if (this.consumerGroup == null) {
            if (other.getConsumerGroup() != null) {
                return false;
            }
        } else if (!this.consumerGroup.equals(other.getConsumerGroup())) {
            return false;
        }

        if (messageQueue == null) {
            if (other.getMessageQueue() != null) {
                return false;
            }
        } else if (!messageQueue.equals(other)) {
            return false;
        }
        return true;
    }

    public String getConsumerGroup() {
        return consumerGroup;
    }

    public void setConsumerGroup(String consumerGroup) {
        this.consumerGroup = consumerGroup;
    }

    public MessageQueue getMessageQueue() {
        return messageQueue;
    }

    public void setMessageQueue(MessageQueue messageQueue) {
        this.messageQueue = messageQueue;
    }

    public ProcessQueue getProcessQueue() {
        return processQueue;
    }

    public void setProcessQueue(ProcessQueue processQueue) {
        this.processQueue = processQueue;
    }

    public long getNextOffset() {
        return nextOffset;
    }

    public void setNextOffset(long nextOffset) {
        this.nextOffset = nextOffset;
    }

    public boolean isLockFirst() {
        return lockFirst;
    }

    public void setLockFirst(boolean lockFirst) {
        this.lockFirst = lockFirst;
    }

    @Override
    public String toString() {
        return "PullRequest{" +
                "consumerGroup='" + consumerGroup + '\'' +
                ", messageQueue=" + messageQueue +
                ", processQueue=" + processQueue +
                ", nextOffset=" + nextOffset +
                ", lockFirst=" + lockFirst +
                '}';
    }
}
